package com.xt.feign;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by Administrator on 2017/7/10.
 */
@RestController
public class ConsumerController {

    @Autowired
    private HelloService helloService;

    @Autowired
    private RefactorHelloService refactorHelloService;

    @RequestMapping(value = "/feign-consumer",method = RequestMethod.GET)
    public String helloConsumer(){
        return helloService.hello();
    }

    @RequestMapping(value = "/feign-consumer2",method = RequestMethod.GET)
    public String helloConsumer2(){
        StringBuilder sb = new StringBuilder();
        sb.append(helloService.hello()).append("\n");
        sb.append(helloService.hello("xt")).append("\n");
        sb.append(helloService.hello("xt",20)).append("\n");
        sb.append(helloService.hello(new User("xt",20))).append("\n");
        return sb.toString();
    }

    @RequestMapping(value = "/feign-consumer3",method = RequestMethod.GET)
    public String helloConsumer3(){
        StringBuilder sb = new StringBuilder();
        sb.append(refactorHelloService.hello("xtt")).append("\n");
        sb.append(refactorHelloService.hello("xtt",24)).append("\n");
        sb.append(refactorHelloService.hello(new com.xt.dto.User("xtt",24))).append("\n");
        return sb.toString();
    }

    @RequestMapping(value = "/feign-consumer4",method = RequestMethod.GET)
    public com.xt.dto.User helloConsumer4(){
        StringBuilder sb = new StringBuilder();
        sb.append(refactorHelloService.hello("xtt")).append("\n");
        sb.append(refactorHelloService.hello("xtt",24)).append("\n");
        sb.append(refactorHelloService.hello(new com.xt.dto.User("xtt",24))).append("\n");
        com.xt.dto.User u = refactorHelloService.hello("xtt",24);
        return u;
    }
}
